package com.metaverse.backend.repo;

import com.metaverse.backend.domain.RoomLog;
import com.metaverse.backend.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * 应用配置
 */
public interface RoomLogRepo extends JpaRepository<RoomLog, Long>, JpaSpecificationExecutor<RoomLog> {


    @Query(value = "select * " +
            "from room_log " +
            "where openid = ?1 and room_id = ?2 and round_id = ?3", nativeQuery = true)
    RoomLog findByRoomId(String openid, String room_id, String roundId);

    @Query(value = "select * from room_log where round_id = ?1 order by created_at desc limit 1 ", nativeQuery = true)
    RoomLog findLastByRoundId(String roundId);


    @Query(value = "select * from room_log order by created_at desc limit 1 ", nativeQuery = true)
    RoomLog findLastRoom();


}
